import Phaser from 'phaser'
const _w = document.getElementById('app').getBoundingClientRect().width
export class ScoreBox extends Phaser.GameObjects.Container {
  constructor (config) {
    super(config.scene)
    this.scene = config.scene
    this.text1 = this.scene.add.text(_w / 2, 50, 'SCORE: 0')
    this.text1.setOrigin(0.5, 0.5)
    this.add(this.text1)

    this.scene.add.existing(this)
    window._that.$emitter.on(window._that.$G.UP_POINTS, this.scoreUpdated, this)
  }

  scoreUpdated () {
    this.text1.setText('SCORE: ' + window._that.$model.score)
  }
}
